package 实验八网络编程2;
import java.io.*;  
import java.net.Socket;  
  
public class 八杠二客户端 {  
    public static void main(String[] args) {  
        try (Socket socket = new Socket("localhost", 9999);  
             PrintWriter out = new PrintWriter(socket.getOutputStream(), true);  
             BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {  
            out.println("你是谁？");
            System.out.println("客户端提问：你是谁");
            System.out.println("服务器回复: " + in.readLine());  
           
            out.println("你的爱好是什么？");  
            System.out.println("客户端提问：你的爱好是什么？");
            System.out.println("服务器回复: " + in.readLine());  
            
            out.println("你真的喜欢编java程序吗？"); 
            System.out.println("客户端提问：你真的喜欢编java程序吗？");
            System.out.println("服务器回复: " + in.readLine());  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
}